import type * as Store from './type'
import http from '@/utils/http'

const BASE_URL = '/store/product/rule'


/** @desc 查询商品规则值(规格)列表 */
export function listStoreProductRule(query: Store.StoreProductRulePageQuery) {
  return http.get<PageRes<Store.StoreProductRuleResp[]>>(`${BASE_URL}`, query)
}

/** @desc 查询商品规则值(规格)详情 */
export function getStoreProductRule(id: string) {
  return http.get<Store.StoreProductRuleDetailResp>(`${BASE_URL}/${id}`)
}

/** @desc 新增商品规则值(规格) */
export function addStoreProductRule(data: any) {
  return http.post(`${BASE_URL}`, data)
}

/** @desc 修改商品规则值(规格) */
export function updateStoreProductRule(data: any, id: string) {
  return http.put(`${BASE_URL}/${id}`, data)
}

/** @desc 删除商品规则值(规格) */
export function deleteStoreProductRule(id: string) {
  return http.del(`${BASE_URL}/${id}`)
}

/** @desc 导出商品规则值(规格) */
export function exportStoreProductRule(query: Store.StoreProductRuleQuery) {
  return http.download<any>(`${BASE_URL}/export`, query)
}

/** @desc 新增运费模板 */
export function getAllStoreProductRules() {
  return http.get(`${BASE_URL}/all`)
}